package main

import (
	"fmt"
	"reflect"
)

type student struct {
	name string
	age  int
}

func test(b interface{}) {
	val, ok := b.(student)
	if ok == false {
		return
	}
	fmt.Print(val, ok)
}

func just(args ...interface{}) {
	for index, val := range args {
		switch val.(type) {
		case bool:
			fmt.Printf("bool %d \n", index)
		case int, int8, int16, int32, int64:
			fmt.Printf("int %d \n", index)
		case student:
			fmt.Print("bool")
		}

	}
}

func testInt(a interface{}){
	val := reflect.ValueOf(a)
	val.Elem().SetInt(10)  //Elem() 相当于*a

	c:= val.Elem().Int()  //取值
	fmt.Print(c)
}

func convert(in interface{})  {
	i, ok := in.(int)
	if ok {
		fmt.Printf("%d成功",i)
		return
	}
	fmt.Print("失败")

}

func main() {
	var stu student
	test(stu)
	just(1, "cici", stu)
	var a int = 1
	testInt(&a)
	convert(a)
}
